Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert vec references to slices #4133

Merged
merged 2 commits into from
Jan 23, 2024
Merged

Conversation

michaeljklein
Copy link
Contributor

Description

Converts usages of &Vec<T> to &[T]

Problem*

Resolves #679

Summary*

&Vec can be dereferenced into &[T] whereas &[T] is more general.

In all but the following two cases, the type can simply be changed:

  1. Both clone and to_vec perform a copy:
        VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().clone())),
        VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().to_vec())),
  1. Both perform a match on the Option:
        self.name == name && (self.params.is_none() || self.params.as_ref() == Some(params))
        self.name == name && (self.params.is_none() || self.params.as_deref() == Some(params))

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [Exceptional Case] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@michaeljklein michaeljklein added the enhancement New feature or request label Jan 23, 2024
Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jfecher jfecher enabled auto-merge January 23, 2024 19:57
@jfecher jfecher added this pull request to the merge queue Jan 23, 2024
Merged via the queue into master with commit 2645c10 Jan 23, 2024
31 checks passed
@jfecher jfecher deleted the michaeljklein/vec-ref-to-slice branch January 23, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore cases where we can change &Vec<T> to &[T]
2 participants